#ifndef GUI_SCROLLER_H
#define GUI_SCROLLER_H

#include <string>
#include <vector>

//#include "BaseElement.h"
#include "gdn/GDN.h"
#include "gui/Button.h"

#define GUI_SCROLLER_IDLE 0
#define GUI_SCROLLER_HOVER 1
#define GUI_SCROLLER_PRESS 2
#define GUI_SCROLLER_RELEASE 3

#define GUI_SCROLLER_HOLD 4
#define GUI_SCROLLER_UP 5
#define GUI_SCROLLER_DOWN 6

namespace gui
{
	class Scroller //: BaseElement
	{
		public:
			Scroller();
			Scroller( const gdn::Vector2f& thePos, gdn::Vector2f theSize, const std::vector< std::string >& theList, size_t theDefault,
					  gdn::Image& theImageUp, gdn::Image& theImageDown, gdn::Image& theImageScrollField, gdn::Image& theImageScrollBar, gdn::Image& theImageBackground, gdn::Image& theImageHighlight,
					  gdn::Font& theFont, unsigned int theCharSize,

					  gdn::Rectanglei theRectUpIdle, gdn::Rectanglei theRectUpHover, gdn::Rectanglei theRectUpPress,

					  gdn::Rectanglei theRectDownIdle, gdn::Rectanglei theRectDownHover, gdn::Rectanglei theRectDownPress,

					  gdn::Rectanglei theRectBarTopIdle, gdn::Rectanglei theRectBarTopHover, gdn::Rectanglei theRectBarTopPress,
					  gdn::Rectanglei theRectBarIdle, gdn::Rectanglei theRectBarHover, gdn::Rectanglei theRectBarPress,
					  gdn::Rectanglei theRectBarBottomIdle, gdn::Rectanglei theRectBarBottomHover, gdn::Rectanglei theRectBarBottomPress,

					  gdn::Rectanglei theRectBackTopLeft, gdn::Rectanglei theRectBackTop, gdn::Rectanglei theRectBackTopRight,
					  gdn::Rectanglei theRectBackLeft, gdn::Rectanglei theRectBack, gdn::Rectanglei theRectBackRight,
					  gdn::Rectanglei theRectBackBottomLeft, gdn::Rectanglei theRectBackBottom, gdn::Rectanglei theRectBackBottomRight );

			virtual int  Process( const gdn::Event& event );
			virtual void Draw( gdn::Window& window );
			virtual void Draw( gdn::RenderImage& renderImage );

			virtual std::string GetSelectedItem() const;

		protected:
			gdn::Vector2f pos;
			gdn::Vector2f size;
			gdn::Vector2f mousePos;

			std::vector< std::string > list;
			size_t defaultItem;
			size_t current;
			size_t top;
			size_t bottom;
			bool hold;

			gdn::Image* imageUpSet;
			gdn::Image* imageDownSet;
			gdn::Image* imageScrollField;
			gdn::Image* imageScrollBar;
			gdn::Image* imageBackground;
			gdn::Image* imageHighlight;
			gdn::Font* font;
			unsigned int charSize;

			gdn::Rectanglei rectUpIdle;
			gdn::Rectanglei rectUpHover;
			gdn::Rectanglei rectUpPress;

			gdn::Rectanglei rectDownIdle;
			gdn::Rectanglei rectDownHover;
			gdn::Rectanglei rectDownPress;

			gdn::Rectanglei rectBarTopIdle;
			gdn::Rectanglei rectBarTopHover;
			gdn::Rectanglei rectBarTopPress;
			gdn::Rectanglei rectBarIdle;
			gdn::Rectanglei rectBarHover;
			gdn::Rectanglei rectBarPress;
			gdn::Rectanglei rectBarBottomIdle;
			gdn::Rectanglei rectBarBottomHover;
			gdn::Rectanglei rectBarBottomPress;

			gdn::Rectanglei rectBackTopLeft;
			gdn::Rectanglei rectBackTop;
			gdn::Rectanglei rectBackTopRight;
			gdn::Rectanglei rectBackLeft;
			gdn::Rectanglei rectBack;
			gdn::Rectanglei rectBackRight;
			gdn::Rectanglei rectBackBottomLeft;
			gdn::Rectanglei rectBackBottom;
			gdn::Rectanglei rectBackBottomRight;

			gdn::Sprite backSprite;
			gdn::Sprite scrollFieldSprite;
			gdn::Sprite barSprite;
			gdn::Sprite highlightSprite;
			gui::Button upButton;
			gui::Button downButton;

			gdn::Rectanglef  bar;
			gdn::Rectanglei* barTopRect;
			gdn::Rectanglei* barRect;
			gdn::Rectanglei* barBottomRect;

			virtual void ProcessBarHighlight( const gdn::Event& event );
			virtual void DrawBackground( gdn::RenderImage& renderImage );

			virtual void DrawBar( gdn::RenderImage& bar );
			virtual void ResizeBar();
			virtual void MoveBar();

			virtual void CalculateDisplayText();

			virtual void ProcessTextSelection( const gdn::Event& event );

			//gdn::Image scrollFieldCache;
			gdn::Image boxCache;
	};
}

#endif // GUI_SCROLLER_H


